<?php
class MediacategoriesTable extends Zend_Db_Table_Abstract
{
    protected $_name = 'mediaaccess';
    protected $_primary = 'id';
    
    public function getMyCategories($parentCategory=0)
    {
    	$db = zend_registry::get('db');
    	
    	$userdata = new Zend_Session_Namespace('userdata');
    	$userrole = $db->quote($userdata->userrole);
    	
    	$select  = "SELECT	c.*
					FROM	mediacategories c, mediaaccess a
					WHERE	c.id = a.categoryid	AND
							a.role = ".$userrole." AND
							a.readfile = 1 AND c.parent = " . $db->quote($parentCategory,'INTEGER');

    	//echo $select; exit;
    	
    	$categories = $db->fetchAll($select);
    	return $categories;
    }
}